//
//  PendApprovalHaveFormTableViewCell.m
//  ZJControlsClass
//
//  Created by mac on 2024/12/12.
//

#import "PendApprovalHaveFormTableViewCell.h"

@implementation PendApprovalHaveFormTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        
        [self.contentView addSubview:self.leftLabel];
        [self.contentView addSubview:self.rightLabel];
        [self.contentView addSubview:self.v];
        
        [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(15);
            make.height.equalTo(@(ALIGN_HEIGHT_PT(44)));
        }];
        
        [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.leftLabel);
            make.left.equalTo(self.leftLabel.mas_right).with.offset(10);
            make.height.equalTo(@(ALIGN_HEIGHT_PT(44)));
            make.right.equalTo(self.contentView).offset(-15);
        }];
        
        [self.v mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.leftLabel.mas_left);
            make.right.equalTo(self.rightLabel.mas_right);
            make.top.equalTo(self.rightLabel.mas_bottom);
            make.height.equalTo(@(1));
        }];
        
    }
    return self;
}


-(void)reloadLabel:(NSMutableDictionary *)dic{
    
    NSString *value = dic[@"leftName"];
    NSArray *components = [value componentsSeparatedByString:@"&"];
    
    if (components.count >= 2) {
        self.leftLabel.text = [components[0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        
        NSString * str = [components[1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        if ([str containsString:@"agree"]) {
            if ([str isEqualToString:@"agree"]){
                str = @"同意";
            }else{
                str = @"不同意";
            }
            
        }
        
        if ([str isEqualToString:@"<null>"]){
            str = @"";
        }
        
        self.rightLabel.text = str;
        
    } else {
        self.leftLabel.text = @"";
        self.rightLabel.text = value;
    }
    
}



#pragma Mark -- 懒加载
- (UILabel *)leftLabel {
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc] init];
        _leftLabel.font = FONT14;
        _leftLabel.textColor = [UIColor grayColor];
    }
    return _leftLabel;
}

- (UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc] init];
        _rightLabel.font = [UIFont systemFontOfSize:14];
        _rightLabel.textColor = [UIColor blackColor];
    }
    return _rightLabel;
}

-(UIView *)v{
    if (!_v){
        _v = [UIView new];
        _v.backgroundColor = COLOR_RGB(244, 244, 244);
    }
    return _v;
}

@end
